package hypeerweb;

import java.io.Serializable;

/**
 * A class that extends the NodeState class to help keep track of which nodes are in a standard state.<br>
 * Domain: STATE_ID : int
 * 
 * @author tbrunner
 */
public class StandardNodeState extends NodeState implements Serializable {
	private static final long serialVersionUID = 6511284306716840387L;

	/**
	 * The StandardNodeState's singleton
	 */
	public static StandardNodeState singleton;

	/**
	 * The integer value that represents which state the Node is in
	 */
	public static final int STATE_ID = 0;

	/**
	 * Default constructor
	 */
	private StandardNodeState() {}

	/**
	 * Method getSingelton finds out if the singleton has been initialized or not, if not initializes it then returns the StandardNodeState singelton
	 * 
	 * @param singelton
	 *            the
	 * @return StandardNodeState singleton
	 */
	public static StandardNodeState getSingleton() {
		if (singleton == null) {
			singleton = new StandardNodeState();
		}
		return (StandardNodeState) singleton;
	}

	/**
	 * Finds the CapNode from a node that is in the StandardState
	 * 
	 * @param refNode
	 *            the node we are using to try and find the capNode from.
	 * @pre refNode != NULL
	 * @post returns the findCapNodeFrom result of the method call from refNode's largest neighbor
	 */
	public Node findCapNodeFrom(Node refNode) {
		assert refNode != null;
		Node largestNeighbor = refNode.getLargestNeighbor();
		return largestNeighbor.getState().findCapNodeFrom(largestNeighbor);
	}

	/**
	 * Method getStateID returns the enumerated id of this state
	 * 
	 * @pre <i>None</i>
	 * @post result = STATE_ID
	 */
	public int getStateId() {
		return STATE_ID;
	}

	/**
	 * Method toString returns the string value of this NodeState
	 * 
	 * @pre <i>None</i>
	 * @post result = "Standard Node State"
	 */
	public String toString() {
		return "Standard Node State";
	}
}